package com.meizi.codegenerate.generate.clien.domain.enums;

import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.Modifier;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.body.*;
import com.github.javaparser.ast.expr.*;
import com.github.javaparser.ast.stmt.*;
import com.github.javaparser.ast.type.ClassOrInterfaceType;
import com.meizi.codegenerate.constant.CharacteristicConstant;
import com.meizi.codegenerate.constant.ExplanatoryNoteConstant;
import com.meizi.codegenerate.constant.JavaClassNameConstant;
import com.meizi.codegenerate.constant.TableNameConstant;
import com.meizi.codegenerate.entity.ProjectPositionEntity;
import com.meizi.codegenerate.packagegenerate.PackageGenerate;
import com.meizi.codegenerate.utils.AttributeConvertUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author pc
 * @date 2023/5/16 - 17:25 - 星期二
 * @project lambda
 * @package com.meizi.codegenerate.generate.clien.domain.enums
 * @by GGbomd猪猪侠
 * 枚举类生成
 */
@Slf4j
public class EnumGenerate {


    /**
     * 根据模板生成枚举
     *  @enum(
     * zero=0==自主注册,
     * one=1==专员邀请,
     * two=2==后台注册
     *  )enum
     * @param tableName 表名
     * @param Field 字段名
     * @param columnComment 注释
     */
    public static void createEnum(String tableName, String Field, String columnComment) throws IOException {

        // 在相应的路径下创建对应的文件
        ProjectPositionEntity projectPosition = PackageGenerate.getProjectPosition();
        String enumsUrl = PackageGenerate.obtainEnumsUrl(projectPosition);

        //获取根据表名和枚举字段名生成枚举实体类
        String className = AttributeConvertUtils.tableNameToJava
                (tableName, TableNameConstant.TABLE_PREFIX, true)
                + AttributeConvertUtils.tableNameToJava(Field, TableNameConstant.TABLE_PREFIX, true)
                + JavaClassNameConstant.ENUMS;
        // 获取完成的文件路径创建文件
        String fullPath = enumsUrl + className + TableNameConstant.JAVA;
        log.info("创建enum路径 fullPath = {}", fullPath);

        CompilationUnit compilationUnit = new CompilationUnit();
        // 添加Package
        compilationUnit.setPackageDeclaration(PackageGenerate.EnumsPackage(projectPosition));
        // 添加枚举的类文件
        EnumDeclaration enumDeclaration = compilationUnit.addEnum(className).setPublic(true);
        // 添加类级别的注释
        enumDeclaration.setJavadocComment("@author GG Bond");

        // 校验枚举注释模板是都按照对应规则生成
        if (checkEnum(columnComment)) {
            // 截取@enum()enum@ 中间的字符串
            int i = columnComment.lastIndexOf(CharacteristicConstant.ENUM_STARTS);
            String substring = columnComment.substring(i);
            String extracted = substring.substring(CharacteristicConstant.ENUM_STARTS.length(), substring.length() - CharacteristicConstant.ENUM_END_TIME.length());
            // 是否包含中英文逗号，
            int on1 = extracted.indexOf("，");
            int on2 = extracted.indexOf(",");
            if (on1 != -1 || on2 != -1) {
                // 切割之后 zero=0==自主注册
                String[] split = extracted.split("[,，]");
                Integer flag = 0;
                for (String str : split) {
                    int end = str.indexOf(CharacteristicConstant.IS_EQUAL_TO);
                    int endIndex = str.indexOf(CharacteristicConstant.DOUBLE_EQUAL_SIGN);
                    if (end != 0 && endIndex != -1) {
                        // 将key 字母转大写
                        String key = StringUtils.isBlank(str.substring(0, end)) ? str.substring(0, end) : str.substring(0, end).toUpperCase();
                        String value = str.substring(end + 1, endIndex);
                        String desc = str.substring(endIndex + 2);
                        // 添加枚举长量 第一次添加注释
                        if (flag.equals(0)) {
                            EnumConstantDeclaration constant = enumDeclaration.addEnumConstant(key).setJavadocComment(columnComment);
                            NodeList<Expression> expressions = new NodeList<>();
                            expressions.add(new IntegerLiteralExpr(value));
                            expressions.add(new StringLiteralExpr(desc));
                            constant.setArguments(expressions);
                            flag++;
                            continue;
                        }
                        EnumConstantDeclaration constant = enumDeclaration.addEnumConstant(key);
                        NodeList<Expression> expressions = new NodeList<>();
                        expressions.add(new IntegerLiteralExpr(value));
                        expressions.add(new StringLiteralExpr(desc));
                        constant.setArguments(expressions);
                    }
                }

                // 将变量添加到枚举类中
                enumDeclaration.addField(Integer.class, ExplanatoryNoteConstant.ENUM_VALUE, Modifier.Keyword.PRIVATE);
                enumDeclaration.addField(String.class, ExplanatoryNoteConstant.ENUM_DESC, Modifier.Keyword.PRIVATE);
                //创建一个FieldDeclaration类型的AST节点，并设置它的修饰符为"private static volatile"，
                // 类型为List<Map<String, Object>>，名称为"cache"，初始值为null：
                FieldDeclaration fieldDeclaration = new FieldDeclaration();
                fieldDeclaration.setPrivate(true);
                fieldDeclaration.setStatic(true);
                fieldDeclaration.setVolatile(true);
                // 添加泛型参数
                ClassOrInterfaceType mapType = new ClassOrInterfaceType(Map.class.getSimpleName());
                mapType.setTypeArguments(new ClassOrInterfaceType(String.class.getSimpleName()), new ClassOrInterfaceType(Object.class.getSimpleName()));
                ClassOrInterfaceType listType = new ClassOrInterfaceType(List.class.getSimpleName());
                listType.setTypeArguments(mapType);
                fieldDeclaration.setJavadocComment(ExplanatoryNoteConstant.ENUM_CACHE_EXPLANATION_CONSTANT).getVariables().add(new VariableDeclarator().setName(ExplanatoryNoteConstant.ENUM_CACHE)
                        .setType(listType).setInitializer(new NullLiteralExpr()));
                // 将 FieldDeclaration 添加到 EnumDeclaration 中
                enumDeclaration.addMember(fieldDeclaration);

                // 创建有参构造函数
                ConstructorDeclaration constructor = enumDeclaration.addConstructor();
                // 添加参数
                constructor.addParameter(new Parameter().setType(Integer.class).setName(ExplanatoryNoteConstant.ENUM_VALUE));
                constructor.addParameter(new Parameter().setType(String.class).setName(ExplanatoryNoteConstant.ENUM_DESC));
                // 添加构造函数体
                BlockStmt constructorBody = new BlockStmt();
                constructorBody.addStatement(new AssignExpr(new FieldAccessExpr(new ThisExpr(), ExplanatoryNoteConstant.ENUM_VALUE),
                        new NameExpr(ExplanatoryNoteConstant.ENUM_VALUE), AssignExpr.Operator.ASSIGN));
                constructorBody.addStatement(new AssignExpr(
                        new FieldAccessExpr(new ThisExpr(), ExplanatoryNoteConstant.ENUM_DESC),
                        new NameExpr(ExplanatoryNoteConstant.ENUM_DESC), AssignExpr.Operator.ASSIGN));
                constructor.setBody(constructorBody);

                // 生成变量的get方法
                enumDeclaration.addMember(get(Integer.class, ExplanatoryNoteConstant.ENUM_VALUE));
                enumDeclaration.addMember(get(String.class, ExplanatoryNoteConstant.ENUM_DESC));
                enumDeclaration.addMember(getCache(ExplanatoryNoteConstant.ENUM_CACHE));

                // 生成构造方法
                //生成from方法
                MethodDeclaration fromMethod = methodDeclarationFrom(enumDeclaration, "from");
                enumDeclaration.addMember(fromMethod);

                // 生成 containsValue 方法
                MethodDeclaration containsValueMethod = methodDeclaration(enumDeclaration, "containsValue", "value",
                        Integer.class, ExplanatoryNoteConstant.ENUM_VALUE,ExplanatoryNoteConstant.CHECK_ENUM_VALUE);
                enumDeclaration.addMember(containsValueMethod);

                //生成 validation 方法
                MethodDeclaration validationValueMethod = methodDeclaration(enumDeclaration, "validation", "desc",
                        String.class, ExplanatoryNoteConstant.ENUM_DESC,ExplanatoryNoteConstant.CHECK_ENUM_DESC);
                enumDeclaration.addMember(validationValueMethod);

                //生成 toDict 方法
                MethodDeclaration toDictValueMethod = methodDeclarationToDict(enumDeclaration, "toDict");
                enumDeclaration.addMember(toDictValueMethod);
            }
        }

        log.info("生成枚举类 compilationUnit = {}", compilationUnit.toString());

        /**
         * 把字符串写入文件
         * 参数1：需要写入的文件，如果文件不存在，将自动创建。  参数2：需要写入的内容
         * 参数3：编码格式     参数4：是否为追加模式（ ture: 追加模式，把字符串追加到原内容后面）
         */
        FileUtils.writeStringToFile(new File(fullPath), compilationUnit.toString(), "UTF-8", false);
    }

    private static MethodDeclaration methodDeclarationToDict(EnumDeclaration enumDeclaration, String methodName) {

        // 添加返回值类型
        ClassOrInterfaceType mapType = new ClassOrInterfaceType(Map.class.getSimpleName());
        mapType.setTypeArguments(new ClassOrInterfaceType(String.class.getSimpleName()), new ClassOrInterfaceType(Object.class.getSimpleName()));
        ClassOrInterfaceType listType = new ClassOrInterfaceType(List.class.getSimpleName());
        listType.setTypeArguments(mapType);

        //创建方法
        MethodDeclaration method = new MethodDeclaration()
                .setModifiers(Modifier.Keyword.PUBLIC, Modifier.Keyword.STATIC)
                .setType(listType)
                .setName(methodName)
                .setJavadocComment(ExplanatoryNoteConstant.CHECK_ENUM_TO_DICT);

        // 创建 if 条件判断语句
        IfStmt ifStmtNotNULL = new IfStmt();
        ifStmtNotNULL.setCondition(new BinaryExpr(new NameExpr("cache"), new NullLiteralExpr(), BinaryExpr.Operator.NOT_EQUALS));
        ReturnStmt returnStmt = new ReturnStmt(new NameExpr("cache"));
        ifStmtNotNULL.setThenStmt(returnStmt);
        method.setBody(new BlockStmt().addStatement(ifStmtNotNULL));

        //创建 if(cache == null)
        IfStmt ifStmtNULL = new IfStmt();
        ifStmtNULL.setCondition(new BinaryExpr(new NameExpr("cache"), new NullLiteralExpr(), BinaryExpr.Operator.EQUALS));

        // 创建Synchronized
        SynchronizedStmt synchronizedStmt = new SynchronizedStmt();
        synchronizedStmt.setExpression(new ClassExpr(new ClassOrInterfaceType(enumDeclaration.getName().asString())));
        IfStmt repeatIfStmtNULL = new IfStmt();
        repeatIfStmtNULL.setCondition(new BinaryExpr(new NameExpr("cache"), new NullLiteralExpr(), BinaryExpr.Operator.EQUALS));

        // 创建 List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        ObjectCreationExpr initializationExpr = new ObjectCreationExpr(
                null, new ClassOrInterfaceType(ArrayList.class.getSimpleName()).setTypeArguments(mapType), NodeList.nodeList());
        VariableDeclarator variableDeclarator = new VariableDeclarator(listType,
                "list", initializationExpr);
        VariableDeclarationExpr variableDeclarationExpr = new VariableDeclarationExpr(variableDeclarator);
        BlockStmt blockStmt = new BlockStmt();
        blockStmt.addStatement(variableDeclarationExpr);
        repeatIfStmtNULL.setThenStmt(blockStmt);

        //创建for循环依次赋值
        VariableDeclarationExpr varForEach = new VariableDeclarationExpr(
                new VariableDeclarator(
                        new ClassOrInterfaceType(null, enumDeclaration.getName().asString()),
                        "t"
                )
        );
        ForEachStmt forEachStmt = new ForEachStmt();
        forEachStmt.setVariable(varForEach);
        forEachStmt.setIterable(new MethodCallExpr(new NameExpr(enumDeclaration.getName().asString()), ExplanatoryNoteConstant.ENUM_VALUES));

        //创建Map<String, Object> tempMap = new HashMap<String, Object>();
        ObjectCreationExpr mapExpr = new ObjectCreationExpr(
                null, new ClassOrInterfaceType(HashMap.class.getSimpleName()).setTypeArguments(
                        new ClassOrInterfaceType(String.class.getSimpleName()), new ClassOrInterfaceType(Object.class.getSimpleName())), NodeList.nodeList());
        VariableDeclarator mapVariableDeclarator = new VariableDeclarator(mapType,
                "tempMap", mapExpr);
        VariableDeclarationExpr mapVariableDeclarationExpr = new VariableDeclarationExpr(mapVariableDeclarator);

        // 添加tempMap 赋值语句
        // 创建 tempMap.put("value", t.getValue()) 表达式语句
        String value = "get" + ExplanatoryNoteConstant.ENUM_VALUE.substring(0, 1).toUpperCase() + ExplanatoryNoteConstant.ENUM_VALUE.substring(1);
        MethodCallExpr putValueExpr = new MethodCallExpr(
                new NameExpr("tempMap"),
                "put",
                NodeList.nodeList(new StringLiteralExpr(ExplanatoryNoteConstant.ENUM_VALUE), new MethodCallExpr(new NameExpr("t"), value, NodeList.nodeList()))
        );
        ExpressionStmt putValueStmt = new ExpressionStmt(putValueExpr);

        NameExpr putExpr = new NameExpr("tempMap");
        // 创建 tempMap.put("desc", t.getDesc()) 表达式语句
        StringLiteralExpr descExpr = new StringLiteralExpr(ExplanatoryNoteConstant.ENUM_DESC);
        // 创建 t.getDesc() 表达式
        String desc = "get" + ExplanatoryNoteConstant.ENUM_DESC.substring(0, 1).toUpperCase() + ExplanatoryNoteConstant.ENUM_DESC.substring(1);
        MethodCallExpr getDescExpr = new MethodCallExpr(new NameExpr("t"), desc);
        // 创建 put("desc", t.getDesc()) 表达式
        Expression descAssignExpr = new MethodCallExpr(putExpr, "put", NodeList.nodeList(descExpr, getDescExpr));

        //创建 list.add(tempMap);
        MethodCallExpr listAddExpr = new MethodCallExpr(
                new NameExpr("list"),
                "add",
                NodeList.nodeList(new NameExpr("tempMap"))
        );

        // forEachStmt 添加tempMap 添加赋值语句
        forEachStmt.setBody(new BlockStmt().addStatement(mapVariableDeclarationExpr));
        forEachStmt.getBody().ifBlockStmt((body -> { body.addStatement(putValueStmt); }));
        forEachStmt.getBody().ifBlockStmt((body -> { body.addStatement(descAssignExpr); }));
        forEachStmt.getBody().ifBlockStmt((body -> { body.addStatement(listAddExpr); }));

        // 在for外层添加 cache = list;
        AssignExpr assignExpr = new AssignExpr(new NameExpr("cache"), new NameExpr("list"), AssignExpr.Operator.ASSIGN);
        // 添加for
        blockStmt.addStatement(forEachStmt);
        // 添加在循环体外创建的语句
        // 加入 ForEachStmt 节点到方法体的语法块中
        blockStmt.addStatement(assignExpr);

        //repeatIfStmtNULL.getThenStmt().ifBlockStmt((body) -> body.addStatement(forEachStmt));

        // 添加 synchronized
        synchronizedStmt.setBody(new BlockStmt().addStatement(repeatIfStmtNULL));
        ifStmtNULL.setThenStmt(synchronizedStmt);

        // 添加外层return
        ReturnStmt stmt = new ReturnStmt(new NameExpr("cache"));
        method.getBody().ifPresent(body -> body.addStatement(ifStmtNULL));
        method.getBody().ifPresent(body -> body.addStatement(stmt));
        return method;
    }

    private static MethodDeclaration methodDeclaration(EnumDeclaration enumDeclaration, String methodName, String parameterStr,
                                                       Class<?> clas, String valueType, String explanatoryNote) {
        MethodDeclaration containsValueMethod = new MethodDeclaration()
                .setModifiers(Modifier.Keyword.PUBLIC, Modifier.Keyword.STATIC)
                .setType(boolean.class.getSimpleName())
                .setName(methodName)
                .addParameter(new Parameter(new ClassOrInterfaceType(null, clas.getSimpleName()), parameterStr))
                .setJavadocComment(explanatoryNote);

        // 创建 Enum[] values = Enum.values();
        ClassOrInterfaceType enumArrayType = new ClassOrInterfaceType(null, enumDeclaration.getName() + "[]");
        VariableDeclarationExpr valuesVar = new VariableDeclarationExpr(
                new VariableDeclarator(
                        enumArrayType,
                        "values",
                        new MethodCallExpr(
                                new NameExpr(enumDeclaration.getName().asString()),
                                "values"
                        )
                )
        );
        // 将 valuesVar 添加到方法体的第一行
        containsValueMethod.setBody(new BlockStmt().addStatement(valuesVar));

        // 添加for 实现
        VariableDeclarationExpr containsValueVarForEach = new VariableDeclarationExpr(
                new VariableDeclarator(
                        new ClassOrInterfaceType(null, enumDeclaration.getName().asString()),
                        "e"
                )
        );
        ForEachStmt containsValueForEachStmt = new ForEachStmt();
        containsValueForEachStmt.setVariable(containsValueVarForEach);
        containsValueForEachStmt.setIterable(new NameExpr(ExplanatoryNoteConstant.ENUM_VALUES));

        // 创建 if 条件判断语句
        NameExpr containsValueValueExpr = new NameExpr(parameterStr);
        String name = "get" + valueType.substring(0, 1).toUpperCase() + valueType.substring(1);
        MethodCallExpr containsValueGetValueExpr = new MethodCallExpr(new NameExpr("e"),
                name);
        NodeList<Expression> nodeList = new NodeList<>();
        nodeList.add(containsValueValueExpr);
        MethodCallExpr containsValueEqualsExpr = new MethodCallExpr(containsValueGetValueExpr, "equals", nodeList);
        ReturnStmt containsValueReturnStmt = new ReturnStmt(new BooleanLiteralExpr(true));
        IfStmt containsValueIfStmt = new IfStmt();
        containsValueIfStmt.setCondition(containsValueEqualsExpr);
        containsValueIfStmt.setThenStmt(containsValueReturnStmt);
        containsValueForEachStmt.setBody(new BlockStmt().addStatement(containsValueIfStmt));

        // 添加外层return
        BooleanLiteralExpr booleanLiteralExpr = new BooleanLiteralExpr(false);
        ReturnStmt returnStmt = new ReturnStmt(booleanLiteralExpr);

        containsValueMethod.getBody().ifPresent(body -> body.addStatement(containsValueForEachStmt));
        containsValueMethod.getBody().ifPresent(body -> body.addStatement(returnStmt));

        return containsValueMethod;
    }

    private static MethodDeclaration methodDeclarationFrom(EnumDeclaration enumDeclaration, String from) {
        // 生成方法
        MethodDeclaration fromMethod = new MethodDeclaration()
                .setModifiers(Modifier.Keyword.PUBLIC, Modifier.Keyword.STATIC)
                .setType(enumDeclaration.getName().asString())
                .setName(from)
                .addParameter(new Parameter(new ClassOrInterfaceType(null, Integer.class.getSimpleName()), "v"))
                .setJavadocComment(String.format(ExplanatoryNoteConstant.ENUM_FROM, enumDeclaration.getName().asString()));

        // 创建代码块，包含 for 循环和 throw 语句
        // 创建 for 循环
        VariableDeclarationExpr varForEach = new VariableDeclarationExpr(
                new VariableDeclarator(
                        new ClassOrInterfaceType(null, enumDeclaration.getName().asString()),
                        "tt"
                )
        );
        ForEachStmt forEachStmt = new ForEachStmt();
        forEachStmt.setVariable(varForEach);
        forEachStmt.setIterable(new MethodCallExpr(new NameExpr(enumDeclaration.getName().asString()), ExplanatoryNoteConstant.ENUM_VALUES));
        // 创建 if 条件判断语句
        NameExpr valueExpr = new NameExpr("v");
        MethodCallExpr getValueExpr = new MethodCallExpr(new NameExpr("tt"),
                "get" + ExplanatoryNoteConstant.ENUM_VALUE.substring(0, 1).toUpperCase() + ExplanatoryNoteConstant.ENUM_VALUE.substring(1));
        NodeList<Expression> list = new NodeList<>();
        list.add(valueExpr);
        MethodCallExpr equalsExpr = new MethodCallExpr(getValueExpr, "equals", list);
        // 创建返回语句
        ReturnStmt returnStmt = new ReturnStmt(new NameExpr("tt"));

        // 创建条件判断语句
        IfStmt ifStmt = new IfStmt();
        ifStmt.setCondition(equalsExpr);
        ifStmt.setThenStmt(returnStmt);
        forEachStmt.setBody(new BlockStmt().addStatement(ifStmt));

        // 创建 throw 语句
        StringLiteralExpr messageExpr = new StringLiteralExpr();
        messageExpr.setString("unknown trade type: ");
        BinaryExpr binaryExpr = new BinaryExpr(messageExpr, new NameExpr("v"), BinaryExpr.Operator.PLUS);
        ClassOrInterfaceType exceptionType = new ClassOrInterfaceType(null, IllegalArgumentException.class.getSimpleName());
        ObjectCreationExpr exceptionExpr = new ObjectCreationExpr(null, exceptionType, NodeList.nodeList(binaryExpr));
        ThrowStmt throwStmt = new ThrowStmt(exceptionExpr);

        // 将 for 循环和 throw 语句添加到方法体中
        fromMethod.getBody().ifPresent(body -> body.addStatement(forEachStmt));
        fromMethod.getBody().ifPresent(body -> body.addStatement(throwStmt));
        return fromMethod;
    }

    private static BodyDeclaration<?> getCache(String enumCache) {
        ClassOrInterfaceType mapType = new ClassOrInterfaceType(Map.class.getSimpleName());
        mapType.setTypeArguments(new ClassOrInterfaceType(String.class.getSimpleName()), new ClassOrInterfaceType(Object.class.getSimpleName()));
        ClassOrInterfaceType listType = new ClassOrInterfaceType(List.class.getSimpleName());
        listType.setTypeArguments(mapType);

        FieldAccessExpr fieldExpr = new FieldAccessExpr(new ThisExpr(), enumCache);
        return new MethodDeclaration()
                .setName("get" + enumCache.substring(0, 1).toUpperCase() + enumCache.substring(1))
                .setModifiers(Modifier.Keyword.PUBLIC)
                .setType(listType)
                .setBody(new BlockStmt().addStatement(new ReturnStmt(fieldExpr)));
    }

    private static BodyDeclaration<?> get(Class<?> tClass, String enumValue) {
        FieldAccessExpr fieldExpr = new FieldAccessExpr(new ThisExpr(), enumValue);
        return new MethodDeclaration()
                .setName("get" + enumValue.substring(0, 1).toUpperCase() + enumValue.substring(1))
                .setModifiers(Modifier.Keyword.PUBLIC)
                .setType(tClass)
                .setBody(new BlockStmt().addStatement(new ReturnStmt(fieldExpr)));
    }

    private static String replaceCharacter(String str) {
        String regEx = "|\n|\r|\t";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(str);
        return m.replaceAll("");
    }

    /**
     * 是否包含特殊字符
     * @param str
     * @return
     */
    private static boolean checkCharacter(String str) {
        String regEx = "|\n|\r|\t";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(str);
        return m.find();
    }

    /**
     * 根据模板生成枚举类
     * zero(key:0, value:0)
     * @enum(
     * zero=0==你，
     * one=1==我,
     * two=2==他，
     * )enum@
     *
     * 注释需要用@enum()enum 英文括号包起来
     * ZERO=0==0,ONE=1==我
     * ZERO是枚举名字=0是key==0是对应value表示的含义
     * 每写完一个需要用中文英文，,分割都可以
     */
    private static boolean checkEnum(String columnComment) {
        int i = columnComment.lastIndexOf(CharacteristicConstant.ENUM_STARTS);
        String substring = columnComment.substring(i);
        boolean startsWith = substring.startsWith(CharacteristicConstant.ENUM_STARTS);
        boolean endsWith = substring.endsWith(CharacteristicConstant.ENUM_END_TIME);
        return startsWith && endsWith;
    }
}
